//
//  FTChartView.m
//  FaceTo
//
//  Created by 姚冬元 on 2017/8/9.
//  Copyright © 2017年 chengbangming. All rights reserved.
//

#import "FTChartView.h"
#import "LYSHistogramChart.h"

@implementation FTChartView

- (instancetype)init
{
    self = [super init];
    
    if (self) {
        
        _timelbl = [[UILabel alloc] init];
        _timelbl.text = @"2017年8月1日-2017年8月7日";
        _timelbl.textColor = FontColor;
        _timelbl.font = [UIFont systemFontOfSize:11];
        [self addSubview:_timelbl];
        
        [_timelbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(20);
            make.top.offset(30);
        }];
        
        UIButton *btn = [[UIButton alloc] init];
        [btn setTitle:@"历史记录 >" forState:UIControlStateNormal];
        [btn setTitleColor:FontColor forState:UIControlStateNormal];
        btn.titleLabel.font = LPFont(13);
        [self addSubview:btn];
        
        [btn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(_timelbl);
            make.right.offset(-20);
        }];
        
        
        LYSHistogramChart *chartView = [[LYSHistogramChart alloc] initWithFrame:CGRectMake(0, 60, kSCREEN_WIDTH, 200)];
        [self addSubview:chartView];
        
        chartView.row = 3;
        chartView.column =7;
        chartView.yStyle.lineColor = [UIColor clearColor];
        chartView.columnData = @[@"8月1日",@"8月2日",@"8月3日",@"8月4日",@"8月5日",@"8月6日",@"8月7日"];
        chartView.valueData = @[@"1.8",@"4.1",@"2.2",@"3.8",@"1.7",@"1.3",@"2.3"];
        chartView.histogramWidth = 6;
        chartView.xAxisDataStyle.fontColor = Color(159, 159, 159);
        chartView.xAxisDataStyle.fontSize = 10;
        chartView.yAxisPrecisionScale = 0;
        chartView.yAxisDataStyle.fontColor = Color(159, 159, 159);
        chartView.isPercent = NO;
        chartView.xStyle.lineColor = LineColor;
        chartView.xStyle.lineWidth = 1;
        chartView.histogramFillColor = FTColor;
        chartView.histogramClickFillColor = FTColor;
        [chartView setHistogramClickAction:^(NSInteger index) {
            NSLog(@"%ld",index);
        }];
        [chartView reloadData];

        
        _dayTimelbl =  [[UILabel alloc] init];
        _dayTimelbl.text = @"日均时间：2:30:04";
        _dayTimelbl.textColor = FontColor;
        _dayTimelbl.font = [UIFont systemFontOfSize:11];
        [self addSubview:_dayTimelbl];
        
        [_dayTimelbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
            make.top.offset(280);
        }];

        _dayScorelbl =  [[UILabel alloc] init];
        _dayScorelbl.text = @"日均积分：150分";
        _dayScorelbl.textColor = FontColor;
        _dayScorelbl.font = [UIFont systemFontOfSize:11];
        [self addSubview:_dayScorelbl];
        
        [_dayScorelbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
            make.top.equalTo(_dayTimelbl.mas_bottom).with.offset(10);
        }];

    }
    return self;
}

@end
